var index;
$(function(){
	
	index = parent.layer.getFrameIndex(window.name);
	
	$("#memberId").html('<option value="' + $("#memberIdVal").val() + '">' + $("#memberName").val() + '</option>').trigger("change");
	$("#serviceId").html('<option value="' + $("#serviceIdVal").val() + '">' + $("#serviceName").val() + '</option>').trigger("change");
	
	getSelectMemberInfo("#memberId");
	
	getSelectProjectService("#serviceId");
	
	$('#serviceId').on('change',function(){
		$.ajax({
			url : webroot+ "/serviceInfo/getServiceInfoById.do",
			data : {'id':$('#serviceId').val()},
			type : 'POST',
			dataType : 'json',
			success : function(dataResult) {
				if(dataResult.data){
					$('#amount').val(dataResult.data.amount);
					$('#cycle').val(dataResult.data.cycle);
					$('#yearInterest').val(dataResult.data.yearInterest);
					$('#yearIntePayNum').val(dataResult.data.yearIntePayNum);
					$('#makeOverDate').val(dataResult.data.makeOverDate);
				}
			}
		});
	});
	 
	 $('.submitButton_Bottom span').on('click',function(){
	    	
		 if($('#serviceInfoForm').valid()){
    		 $(this).css('pointer-events','none').css('opacity','0.2');
    		 $.ajax({
					url : webroot+ "/buyService/updateMemberBuyService.do",
					data : $('#serviceInfoForm').serializeObject(),
					type : 'POST',
					dataType : 'json',
					success : function(dataResult) {
						parent.layer.msg(dataResult.msg);
						$('.submitButton_Bottom span').removeAttr("style");
						if(dataResult.type=='2'){
							parent.projectServiceTable().draw();
							parent.layer.close(index);
						}
					}
				});
    	 }
     	
	 });
});



